home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir24 / psi110g.zip / KISSPOLL.C < prev    next >
C/C++ Source or Header  |  1994-04-17  |  2KB  |  59 lines

  1. /* Polled Kiss ala G8BPQ for JNOS
  2.  * Copyright 1993, Johan. K. Reinalda, WG7J
  3.  * Hereby placed in the public domain.
  4.  */
  5. #include "global.h"
  6. #include "slip.h"
  7. #include "kiss.h"
  8. #include "asy.h"
  9. #include "devparam.h"
  10. #include "kisspoll.h"
  11.   
  12. #ifdef POLLEDKISS
  13.   
  14. #define WAITTIME 165L
  15.   
  16. void kiss_poller(int xdev,void *p1,void *p2) {
  17.     int i;
  18.     long interval = (long)p1;
  19.     struct mbuf *bp;
  20.     struct iface *master,*iface;
  21.     struct slip *sp = &Slip[xdev];
  22.   
  23.     /* The actual physical interface */
  24.     master = sp->kiss[0];
  25.   
  26.     while (1) {
  27.         for(i=0;i<16;i++) {
  28.             if((iface=sp->kiss[i]) == NULL)
  29.                 continue;
  30.   
  31.             /* Get buffer for the poll packet, and generate it */
  32.             if((bp = alloc_mbuf(2)) == NULL)
  33.                 continue;
  34.             bp->data[0] = PARAM_POLL;
  35.             bp->data[0] |= (i << 4);
  36.             bp->data[1] = bp->data[0];  /* The checksum */
  37.             bp->cnt = 2;
  38.   
  39.             if(iface->port){
  40.                 iface->rawsndcnt++;
  41.                 iface->lastsent = secclock();
  42.             }
  43.             /* slip_raw also increments sndrawcnt */
  44.             slip_raw(master,bp);
  45.   
  46.             pause(WAITTIME);    /* give time to start sending frame */
  47.   
  48.             if(sp->rx) {
  49.                 /* if frame busy, wait for a full frame (max) */
  50.                 alarm(interval);
  51.                 pwait(&sp->rx);
  52.             }
  53.         }
  54.     }
  55. }
  56.   
  57. #endif /* POLLEDKISS */
  58.   
  59.